<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    
  </head>
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/profile" class="icon icon-left pull-left"></a>
          <h1 class="title">积分商城</h1>
        </header>
        
        <div class="content">
          <!-- Slider -->
          <div class="swiper-container mall-banner" data-space-between='10' style="padding-bottom: 0;">
            <div class="swiper-wrapper">
              <div class="swiper-slide"><img src="${ctx.resource}/image/credit/mall-banner.png" alt=""></div>
              <div class="swiper-slide"><img src="${ctx.resource}/image/credit/mall-banner.png" alt=""></div>
              <div class="swiper-slide"><img src="${ctx.resource}/image/credit/mall-banner.png" alt=""></div>
            </div>
            <!-- <div class="swiper-pagination"></div> -->
          </div>
          
          <c:choose>
            <c:when test="${empty creditCouponBatchs}">
              <div class="content bg-white">
                <div class="coupon-status">
                  <img src="${ctx.resource}/image/logo.png">
                </div>
                <div class="status-hint text-center">
                  <p style="color: #fc0101"> 积分商城正在筹备中...</p>
                  <a href="${ctx.host}/profile" class="button back-btn" style=" ">返回个人中心？</a>
                </div>
              </div>
            </c:when>
            <c:otherwise>
              <div class="list-block no-margin">
                <ul class="mall-record">
                  <li>
                    <div class="item-content for-record">
                      <a href="${ctx.host}/profile/credit-records">
                        <i class="icon icon-record-point" style="width: 1rem; top: -2px; margin-right: 3px;"></i>可兑换积分
                        <span class="color-warning">${empty credit ? 0 : credit.availableCredit}</span>
                      </a>
                      <a href="${ctx.host}/profile/credit-coupons" style="padding-left: .75rem;">
                        <i class="icon icon-record-money" style="width: 1rem; top: -2px; margin-right: 3px;"></i>兑换记录</a>
                    </div>
                  </li>
                </ul>
              </div>
              <div class="row no-gutter">
                <c:forEach items="${creditCouponBatchs}" var="creditCouponBatch">
                    <div class="col-50 coupon-item">
                      <div class="card">
                        <div class="card-header color-white no-border no-padding" style="vertical-align: middle;">
                          <a href="${ctx.host}/credit-coupons/${creditCouponBatch.id}"><img class='card-cover' src="${cloud.prod}/${creditCouponBatch.cover}" alt=""></a>
                        </div>
                        <div class="card-content">
                          <div class="card-content-inner">
                            <a href="${ctx.host}/credit-coupons/${creditCouponBatch.id}">
                              <p class="coupon-info">${creditCouponBatch.templateName}</p>
                              <p class="color-gray coupon-point">积分：<span class="color-red">${creditCouponBatch.creditValue}</span></p>
                              <p class="color-gray coupon-data text-right">
                                <c:if test="${creditCouponBatch.expireType.alias == 'fixed_days'}">有效期为${creditCouponBatch.effectiveDays}天</c:if> 
                                <c:if test="${creditCouponBatch.expireType.alias == 'fixed_date'}">有效期至${creditCouponBatch.effectiveEndDate}</c:if>
                              </p>
                            </a>
                          </div>
                        </div>
                      </div>
                    </div>
                </c:forEach>
              </div>
            </c:otherwise>
          </c:choose>
        </div>
      </div>
    </div>
   
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource type="script" root="${ctx.resource}/build" src="js/page/credit/coupon-mall.js" />
    <script type="text/javascript">
      require(['page/credit/coupon-mall'], function(page) {
        page.init()
      })
    </script>
  </body>
</html>